
#include "stdafx.h"
#include "CommandDef.h"
#include "debug_new.h"
#include "Util/UtilInclude.h"
#include "CSubCon.h"
#include "MainMenuPainter.h"
#include "IResCfg.h"
#include "CMSGInforCon.h"
#include "CSubConPainter.h"

CSubCon::CSubCon(HWND hWnd):CMSGInforCon(hWnd)
{
   m_Rect.SetRect(0,0,355,454);
   m_iPage=0;
   m_iStep=58;
}

CSubCon:: ~CSubCon(void)
{



}

BOOL CSubCon::InitControls(DWORD dwData)
 {

	 ////message box
	 //LANGUAGE_DECLARE;
	 //FONT_DECLARE;

	 //HBITMAP hBitmap = NULL;

	 //CIResCfg ResCon;
	 //if(!ResCon.Init(L"SubMSGClubSet.xml"))
	 //{
		// //g_App.ShowMsgBox(CMD_MSGBOX_OK,L"",LAN_GETTEXT(Msg_ResError));
		// return FALSE;
	 //}

	 //m_nAniType  = ResCon.GetAniType();
	 //m_nExitAniType=ResCon.GetExitAniType();
	 //m_nAniSpeed = ResCon.GetAniSpeed();
	 //SetRect(ResCon.GetRect());
	 //BOOL bFromDll = ResCon.IsResFromDll();
	 //BtnParam btnInfo;

	 //hBitmap = CUtil::LoadBitmapEx(ResCon.GetImage(),bFromDll);


	 //BatTimePicParam picInfo;
	 //CBmpBtn* pBtn = NULL;
	 //TextParam txtInfo;
	 //CText* pText=NULL; 

	 //ResCon.GetBatTimePicParam(picInfo,L"Pic_Bkgnd");
	 //CPicture *pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC, L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	 //ResCon.SetPicParam(pPic,picInfo);

	

	
	 //ResCon.GetBatTimePicParam(picInfo,L"ClubSet_LanBK");
	 //pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	 //ResCon.SetPicParam(pPic,picInfo);

	 //ResCon.GetBatTimePicParam(picInfo,L"ClubSet_Unit");
	 //pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	 //ResCon.SetPicParam(pPic,picInfo);

	 //ResCon.GetBatTimePicParam(picInfo,L"ClubSet_NumberBK1");
	 //pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	 //ResCon.SetPicParam(pPic,picInfo);

	 //ResCon.GetBatTimePicParam(picInfo,L"ClubSet_NumberBK2");
	 //pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	 //ResCon.SetPicParam(pPic,picInfo);


	 //ResCon.GetBatTimePicParam(picInfo,L"ClubSet_KAYAK");
	 //pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	 //ResCon.SetPicParam(pPic,picInfo);

	 //ResCon.GetBatTimePicParam(picInfo,L"ClubSet_CSAFE");
	 //pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	 //ResCon.SetPicParam(pPic,picInfo);



	 //ResCon.GetBatTimePicParam(picInfo,L"LangIcon");
	 //pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	 //ResCon.SetPicParam(pPic,picInfo);

	 //ResCon.GetTextParam(txtInfo,L"CText_LAN");
	 //pText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(MSG_HS_CLUBSETTING_DEFAULTLAN),txtInfo.m_rc, CMD_MSGBOX_TEXT));
	 //ResCon.SetTextParam(pText,txtInfo);

	 //ResCon.GetTextParam(txtInfo,L"CText_UNIT");
	 //pText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(MSG_HS_CLUBSETTING_DEFAULTUNIT),txtInfo.m_rc, CMD_MSGBOX_TEXT));
	 //ResCon.SetTextParam(pText,txtInfo);



	 //ResCon.GetTextParam(txtInfo,L"CText_MAXWORKOUTTIME");
	 //pText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(MSG_HS_CLUBSETTING_WORKOUTTIME_MAX),txtInfo.m_rc, CMD_MSGBOX_TEXT));
	 //ResCon.SetTextParam(pText,txtInfo);

	 //ResCon.GetTextParam(txtInfo,L"CText_MAXPAUSETIME");
	 //pText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(MSG_HS_CLUBSETTING_PAUSETIME_MAX),txtInfo.m_rc, CMD_MSGBOX_TEXT));
	 //ResCon.SetTextParam(pText,txtInfo);

	 //ResCon.GetTextParam(txtInfo,L"CText_CABLEKAYAK");
	 //pText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(MSG_HS_CLUBSETTING_CABLEKATAK),txtInfo.m_rc, CMD_MSGBOX_TEXT));
	 //ResCon.SetTextParam(pText,txtInfo);

	 //ResCon.GetTextParam(txtInfo,L"CText_CSAFE");
	 //pText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(MSG_HS_CLUBSETTING_CSAFE),txtInfo.m_rc, CMD_MSGBOX_TEXT));
	 //ResCon.SetTextParam(pText,txtInfo);



	 //ResCon.GetBtnParam(btnInfo,L"ClubSet_LAN_BTN");
	 //pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_CLUBSET_LAN));
	 //ResCon.SetBtnParam(pBtn,btnInfo);

	 //ResCon.GetBtnParam(btnInfo,L"ClubSet_CHOOSE_BTN");
	 //pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_SUBSET_BTN_UNIT));
	 //ResCon.SetBtnParam(pBtn,btnInfo);


	 //ResCon.GetBtnParam(btnInfo,L"ClubSet_NUM1_BTN_LEFT");
	 //pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_SUBSET_BTN_MAXTIME_LEFT));
	 //ResCon.SetBtnParam(pBtn,btnInfo);



	 //ResCon.GetBtnParam(btnInfo,L"ClubSet_NUM1_BTN_RIGHT");
	 //pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_SUBSET_BTN_MAXTIME_RIGHT));
	 //ResCon.SetBtnParam(pBtn,btnInfo);

	 //ResCon.GetBtnParam(btnInfo,L"ClubSet_NUM2_BTN_LEFT");
	 //pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_SUBSET_BTN_PAUSETIME_LEFT));
	 //ResCon.SetBtnParam(pBtn,btnInfo);


	 //ResCon.GetBtnParam(btnInfo,L"ClubSet_NUM2_BTN_RIGHT");
	 //pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_SUBSET_BTN_PAUSETIME_RIGHT));
	 //ResCon.SetBtnParam(pBtn,btnInfo);

	


	 //BatTimePicParam btpInfo;
	 //ResCon.GetBatTimePicParam(btpInfo,L"Time1_Ctrl");
  //   m_pMaxTimeCtrl = (CTimeCtrl*)AddControl(new CTimeCtrl(SBS_RECT, L"", btpInfo.m_rc, CMD_MSG_SUBSET_MAXTIME));
	 //ResCon.SetTimeParam(m_pMaxTimeCtrl,btpInfo);
	 //m_pMaxTimeCtrl->SetAutoGetSysTime(false);


	 //ResCon.GetBatTimePicParam(btpInfo,L"Time2_Ctrl");
	 //m_pPAUSETimeCtrl = (CTimeCtrl*)AddControl(new CTimeCtrl(SBS_RECT, L"", btpInfo.m_rc, CMD_MSG_SUBSET_PASUETIME));
	 //ResCon.SetTimeParam(m_pPAUSETimeCtrl,btpInfo);
	 //m_pPAUSETimeCtrl->SetAutoGetSysTime(false);


	

	 // SetPainter(new CSubConPainter());
	 return true;
 }

 void  CSubCon::OnLButtonDown(UINT nFlags, CPoint point)
 {

	 int n=m_vecControls.size();
	 CRect rc;
	 for (int i=0;i<n;i++)
	 {
		 rc=m_vecControls[i]->GetRect();
		rc.OffsetRect(GetRect().left,GetRect().top-m_iPage*m_iStep);
		// rc.MoveToXY(GetRect().left,GetRect().top-m_iPage*m_iStep);
		 m_vecControls[i]->SetRect(rc);


		

	 }
   

	 CContainer::OnLButtonDown( nFlags,point );
	

	

 }

void  CSubCon::OnLButtonUp(UINT nFlags, CPoint point)
{
  
	//point.x= point.x-GetRect().left;
	//point.y=point.y-GetRect().top;
    CContainer::OnLButtonUp( nFlags,point );
	CRect rc;
	for (int i=0;i< m_vecControls.size();i++)
	{
		rc=m_vecControls[i]->GetRectCopy();
		m_vecControls[i]->SetRect(rc);
	}
  
  //  CContainer::OnLButtonUp( nFlags,point );
	

}

void CSubCon::SetPage(int page)
{

    m_iPage =page;
	if (m_iPage>2)
	{
      m_iPage=2;

	}

	if (m_iPage<0)
	{
		m_iPage=0;

	}
	m_Rect.SetRect(0,m_iPage*m_iStep,355,454+m_iPage*m_iStep);
	
}